//
//  MAPYSettingPrivacyViewController.swift
//  Mars Proxy
//
//  Created by PowerfullClean on 2023/10/20.
//

import UIKit
import WebKit
class MAPYSettingPrivacyViewController: MAPYBaseViewController, WKNavigationDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(mapy_mainavView)
        view.addSubview(mapy_wkView)
        view.addSubview(mapy_loading)
        
        mapy_wkView.snp.makeConstraints { make in
            make.bottom.width.leading.equalToSuperview()
            make.top.equalTo(mapy_mainavView.snp.bottom)
        }
        
        mapy_loading.snp.makeConstraints { make in
            make.size.equalTo(110)
            make.centerX.centerY.equalToSuperview()
        }
        mapy_wkView.load(URLRequest.init(url: URL.init(string: "https://sites.google.com/view/marsproxy/")!))
    }
    
    //MARK: - mapy action
    func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
        mapy_loading.startAnimating()
    }
    
    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        mapy_loading.stopAnimating()
        
    }
    
    func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
        mapy_loading.stopAnimating()
        
    }
    //MARK: - mapy lazy
    lazy var mapy_mainavView: MAPYNavView = {
        let mapy_mainavView = MAPYNavView()
        return mapy_mainavView
    }()
    
    lazy var mapy_wkView: WKWebView = {
        let mapy_wkView = WKWebView()
        mapy_wkView.navigationDelegate = self
        
        return mapy_wkView
    }()
    
    lazy var mapy_loading: UIActivityIndicatorView = {
        let mapy_loading = UIActivityIndicatorView()
        mapy_loading.style = UIActivityIndicatorView.Style.medium
        return mapy_loading
    }()
    
}
